<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRecordsTable extends Migration
{
    /**
     * IP以及ua同时不相同时代表一个独立访问
     *
     * @return void
     */
    public function up()
    {
        Schema::create('records', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('picture_id');
            $table->tinyInteger('type')->default(1)
                ->comment('记录类型，1：浏览记录，2：下载记录，3：点赞记录');
            $table->ipAddress('ip');
            $table->string('ua')->comment('浏览器的ua');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('records');
    }
}
